|
|
|
| 11. Add the following code for the DragOver event for the new imaPicture control: | | Private Sub imaPicture_DragOver(Index As Integer, _
Source As Control, x As Single, _
y As Single, State As Integer)
If TypeOf Source Is ListBox Then If Source.Text = imaPicture(Index).Tag Then If State = vbEnter Then Source.DragIcon = _
imlList.ListImages("DropPage").Picture ElseIf State = vbLeave Then Source.DragIcon = _
imlList.ListImages("Folder").Picture End If
End If
End If
End Sub |  | In this code, a new argument is passed to the DragOver eventthe Index property of the control you just dragged over. You now need to use that index to compare the Text property in the list box against the Tag property of the image control. Now, you can also set the DragIcon property by retrieving the Picture property of the ListImages collection where the Key property is DropPage or Folder, depending on whether youre leaving the control or not. You can also change the MouseDown event to pull the folder picture when resetting the DragIcon property, as shown in the following source code: | | Private Sub lstThings_MouseDown(Button As Integer, _
Shift As Integer, x As Single, y As Single) lstThings.DragIcon = imlList.ListImages("Folder").Picture lstThings.Drag vbBeginDrag
End Sub |
|
|
|
|
|
|
When youre positioned over the correct image control and you let go of the mouse button, the DragDrop event is fired on the image control. You can now remove the item from the list box. You need to add the following code to replace the code you deleted for the old controls. Notice, again, that you use the Index argument thats passed in: |
|
|
|
|
|